package com.itheima.listener;

import com.itheima.domain.db.MovementScore;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.stereotype.Component;

/**
 * 创建监听服务
 * @author zsk
 * @create 2022-03-27-16:13
 */
@Component
public class MovementScoreListener {

    @Autowired
    private MongoTemplate mongoTemplate;


    @RabbitListener(queuesToDeclare = @Queue("tanhua.recommend.movement"))
    public void listenMovementScore(MovementScore movementScore){
        System.out.println("接受动态评分日志：" +movementScore);
        mongoTemplate.save(movementScore);

    }

}
